package etp.client.gui;

import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.TextBox;

public class LoginScreen extends Composite {
	
	private Label lblErro = new Label("");
	
	private Label lblLogin = new Label("email:");
	
	private TextBox txtLogin = new TextBox();

	private Label lblPassword = new Label("senha:");
	
	private PasswordTextBox txtPassword = new PasswordTextBox();
	
	private Button btnLoggin = new Button("Entrar");
	
	public LoginScreen(){
		
		this.lblErro.addStyleName("ErrorLabel");
		
		FlexTable tblMain = new FlexTable();
		
		tblMain.setWidget(0, 0, lblErro);
		
		tblMain.setWidget(1, 0, lblLogin);
		tblMain.setWidget(1, 1, txtLogin);
		
		tblMain.setWidget(2, 0, lblPassword);
		tblMain.setWidget(2, 1, txtPassword);
		
		tblMain.setWidget(3, 0, btnLoggin);
	
		tblMain.getFlexCellFormatter().setColSpan(0, 0, 2);
		
		tblMain.getFlexCellFormatter().setColSpan(3, 0, 2);
		
		tblMain.getFlexCellFormatter().setHeight(3,0, "60");
		tblMain.getFlexCellFormatter().setAlignment(3, 0,
				HasHorizontalAlignment.ALIGN_CENTER,
				HasVerticalAlignment.ALIGN_BOTTOM);
		
		this.initWidget(tblMain);
		
		this.setStyleName("etp-LoginScreen");
	}
	
	public String getUsername(){
		return this.txtLogin.getText();
	}

	public String getPassword(){
		return this.txtPassword.getText();
	}
	
	public void addOkClickHandler(ClickHandler handler){
		this.btnLoggin.addClickHandler(handler);
	}
	
	public void showError(String error){
		this.lblErro.setText(error);
	}
}
